package kmp;

public class leetCode125_isPalindrome {

    public boolean isPalindrome(String s) {
        StringBuilder stringBuffer = new StringBuilder();
        int n = s.length();
        for (int i = 0; i < n; i++) {
            if(Character.isLetterOrDigit(s.charAt(i))){
                stringBuffer.append(Character.toLowerCase(s.charAt(i)));
            }
        }
        int i = 0;
        int j = stringBuffer.length() - 1;
        while (i < j){
            if(stringBuffer.charAt(i) != stringBuffer.charAt(j)){
                return false;
            }
            i++;
            j--;
        }
        return true;

    }

}
